package com.itheima.day16.task3;

import java.lang.reflect.Field;

public class MyUtils {

    private MyUtils() {
    }

    public static Object getProperty (Object obj, String fieldName) throws IllegalAccessException, NoSuchFieldException {
        Class<?> aClass = obj.getClass();

        Field fieldName1 = aClass.getDeclaredField(fieldName); //NoSuchFieldException: fieldName  fildName不能打双引号
        fieldName1.setAccessible(true);
        Object o = fieldName1.get(obj);
        return o;


    }
}
